package team.seekers.hula.record.history.controller;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.*;
import team.seekers.hula.common.annotation.ApiResponseBody;
import team.seekers.hula.record.history.entity.dto.HistorySaveDTO;
import team.seekers.hula.record.history.entity.dto.HistoryUpdateDTO;
import team.seekers.hula.record.history.entity.vo.HistoryInfoVO;
import team.seekers.hula.record.history.entity.vo.HistoryListVO;
import team.seekers.hula.record.history.service.HistoryService;

import java.util.List;

/**
 * @author hbc
 * @since 2022-11-22
 */
@Controller
@ApiResponseBody
@RequestMapping("/history")
public class HistoryController {

    @Autowired
    private HistoryService historyService;

    @PostMapping("/add")
    public String add(@RequestBody HistorySaveDTO saveDTO){
        return historyService.save(saveDTO);
    }

    @GetMapping("/delete")
    public void delete(@RequestParam String id){
        historyService.remove(id);
    }

    @PostMapping("/update")
    public void update(@RequestBody HistoryUpdateDTO updateDTO){
        historyService.update(updateDTO);
    }

    @GetMapping("/info")
    public HistoryInfoVO info(@RequestParam String id){
        return historyService.info(id);
    }

    @GetMapping("/list")
    public List<HistoryListVO> list(){
        return historyService.listVO();
    }

}

